package com.thwj.project.app.api;

import com.thwj.framework.web.domain.R;
import com.thwj.project.app.api.vo.MerchantProductVO;
import com.thwj.project.app.service.AppProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@Api(tags="app 商家产品相关接口")
@RestController
@RequestMapping("/app/product")
public class AppMerchantProductController {



    @Autowired
    AppProductService appProductService;

    @ApiOperation(value = "读取指定商家下的产品列表")
    @GetMapping("/getProductList")
    public R<List<MerchantProductVO>> getProductList(@RequestParam Long merchantId) {
        List<MerchantProductVO> productVOList = appProductService.getMerchantProductVOList(merchantId);
        return R.data(productVOList);
    }

    @ApiOperation(value = "读取指定商家下的产品列表")
    @GetMapping("/getProductById")
    public R<MerchantProductVO> getProductById(@RequestParam Long productId) {

        MerchantProductVO merchantProductVO = appProductService.getProductById(productId);
        //
        return R.data(merchantProductVO);
    }


}
